package com.firefly.service.repository.cms;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.firefly.dao.dao.cms.po.ArticlePo;
import com.firefly.dao.dao.cms.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description: 文章
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2022/12/20
 **/
@Repository
public class ArticleRepository {
    private final ArticleService articleService;
    @Autowired
    public ArticleRepository(ArticleService articleService){
        this.articleService = articleService;
    }
    public Boolean create(ArticlePo entity){
        return articleService.save(entity);
    }

    public Boolean update(ArticlePo entity){
        return articleService.updateById(entity);
    }

    public Boolean removeByIds(List<Integer> ids){
        UpdateWrapper<ArticlePo> updateWrapper = new UpdateWrapper<>();
        updateWrapper.in("id", ids);
        updateWrapper.set("del_flag", 1);
        return articleService.update(updateWrapper);
    }
}
